Skip to main content

RouteProcessor3

The RouteProcessor3 contract is used to perform complicated swaps that go through multiple pairs and AMMS. This version of the route processor introduces V3 AMM or concentrated liquidity style of support.

The full contract can be found here.

Read-Only Functions

State-Changing Functions

processRoute

function processRoute(
address tokenIn,
uint256 amountIn,
address tokenOut,
uint256 amountOutMin,
address to,
bytes memory route
) external payable lock returns (uint256 amountOut);

Processes the route generated off-chain for a token swap with a lock to prevent re-entrancy.

This function is a wrapper for the processRouteInternal function. It has a lock modifier to prevent re-entrancy attacks. This function is marked as payable which means it can receive Ether. This is useful in scenarios where the input token is Ether.

The function forwards all the parameters to the processRouteInternal function and returns the output of that function.

Parameters

NameTypeDescription
tokenInaddressThe address of the input token.
amountInuint256The amount of the input token to swap.
tokenOutaddressThe address of the output token.
amountOutMinuint256The minimum amount of the output token that needs to be received.
toaddressThe address where the output tokens should be sent.
routebytesByte-encoded data that describes the route of the swap.

Returns

NameTypeDescription
amountOutuint256The actual amount of the output token received.

transferValueAndprocessRoute

function transferValueAndprocessRoute(
address payable transferValueTo,
uint256 amountValueTransfer,
address tokenIn,
uint256 amountIn,
address tokenOut,
uint256 amountOutMin,
address to,
bytes memory route
) external payable lock returns (uint256 amountOut);

Transfers a specified amount of Ether to an address and then processes a token swap route.

This function first transfers the specified amount of Ether to the transferValueTo address. If the transfer fails, it reverts the transaction with the return data of the failed call.

Then it processes the token swap route by calling the processRouteInternal function with the remaining parameters and returns its output.

The function is marked as payable which means it can receive Ether. This is useful in scenarios where the input token is Ether. It also has a lock modifier to prevent re-entrancy attacks.

Parameters

NameTypeDescription
transferValueToaddress payableThe address to which the Ether is transferred.
amountValueTransferuint256The amount of Ether to transfer.
tokenInaddressThe address of the input token.
amountInuint256The amount of the input token to swap.
tokenOutaddressThe address of the output token.
amountOutMinuint256The minimum amount of the output token that needs to be received.
toaddressThe address where the output tokens should be sent.
routebytesByte-encoded data that describes the route of the swap.

Returns

NameTypeDescription
amountOutuint256The actual amount of the output token received.